//
//  HeadBackView.m
//  WaywardPoint_Code
//
//  Created by 韩盼盼 on 15/11/24.
//  Copyright © 2015年 易网新科技. All rights reserved.
//

#import "HeadBackView.h"

@implementation HeadBackView
-(id)initWithTitle:(NSString *)title andrightBtn:(UIButton *)rightBtn
{
    if (self=[super init]) {
        self.frame=CGRectMake(0, 0, ScreenW, 44+20);
        _headerView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenW, self.height)];
        _headerView.backgroundColor = RXDColor(50, 68, 78);
        [self addSubview:_headerView];


        UIImageView  *backimg=[[UIImageView alloc]initWithFrame:CGRectMake(5, 27, 30, 30)];
        backimg.image=[UIImage imageNamed:@"return_left"];

        [_headerView addSubview:backimg];

        UILabel *titlelab=[[UILabel alloc]initWithFrame:CGRectMake(backimg.width, 30, 140, 25)];
        titlelab.text=title;
        titlelab.textColor=[UIColor whiteColor];
        titlelab.font=[UIFont boldSystemFontOfSize:18];
        [_headerView addSubview:titlelab];

        UIButton *headbtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 20, backimg.width+titlelab.width+20, 44)];
        [headbtn addTarget:self action:@selector(backviewEvent) forControlEvents:UIControlEventTouchUpInside];
        headbtn.backgroundColor=[UIColor clearColor];
        [_headerView addSubview:headbtn];
        
        
        

    }
    return self;
}

+ (instancetype)headbackView:(NSString *)str andrightBtn:(UIButton *)btn
{
    return [[self alloc] initWithTitle:str andrightBtn:btn];
}


- (void)backviewEvent
{
    if ([self.delegate respondsToSelector:@selector(btnback)]) {
        [self.delegate btnback];
    }
    
  
}
@end
